package com.gaojinqi.lock.config;

import com.gaojinqi.lock.IDistributedLock;
import com.gaojinqi.lock.redis.RedisRuaLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.Executor;

/**
 * @author gaojinqi
 * @version 1.0
 * @since 2020年08月19日
 */
@Configuration
public class LockAutoConfiguration {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private Executor executor;

    @Bean
    public IDistributedLock distributedLock() {
        ///return new RedisLock(redisTemplate, executor);
        return new RedisRuaLock(redisTemplate, executor);
    }

}
